#include <vector>

using namespace std;

class Solution {
public:
    void merge(vector<int>& A, int m, vector<int>& B, int n) {
        int cur = m + n - 1;
        m--;
        n--;
        while (m >= 0 && n >= 0) {
            if (A[m] > B[n]) {
                A[cur] = A[m];
                m--;
            } else {
                A[cur] = B[n];
                n--;
            }
            cur--;
        }
        if (n >= 0) {
            for (int i = 0; i <= n; i++) {
                A[i] = B[i];
            }
        }
    }
};